package com.shanzhe.eshop.common.jdk;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author yinwei
 * @create 2021/12/20
 * @Version 1.0
 */
public class FixedThreadPoolDemo {
    public static void main(String[] args) {
         ExecutorService threadPool = Executors.newFixedThreadPool(3);

         for(int i = 0;i<10;i++){
             threadPool.execute(new Runnable() {
                 @Override
                 public void run() {
                     System.out.println("线程池异步执行任务..."+Thread.currentThread());
                 }
             });
         }

        threadPool.shutdown();
    }
}
